#ifndef NEWTONINTERPOLATION_H
#define NEWTONINTERPOLATION_H

class datanode
{
public:
    datanode();
    void init();
    datanode(datanode &temp);
    ~datanode();
    datanode * getnext() const;
    void setnext(datanode* next);
    void setdivideddifferent(double difference,int order);  //order is the absultly order of difference
    double getdata(int order)const;  //if order is 0,return f(x)
    void sety(double y);
    void setnumberorder(int order);
    int getnumberorder() const;
    void setx(double x);
    double getx() const;
    void show()const;
private:
    double m_x;
    double * m_y;         //first is the y ,others are devided difference
    int m_numberorder;// the order of x in {x0,x1,x2....}
    datanode * m_next;

};

class datatalbe
{
public:
    datatalbe();
    ~datatalbe();
    void addnumber(int x,int y);
    void produce();           //to get the divided difference table
    double getx(int n)const ;//n is the number of x
    double getdata(int xth,int n)const;
    int getcount()const;
    void show();

private:
    int m_count;
    datanode * m_data;

};
#endif // NEWTONINTERPOLATION_H
